/**
 * 
 */
package com.thinkgsp.sys.model;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.security.core.GrantedAuthority;

/**
 * 用户角色类
 * @author evan
 *
 */
public class SysRole extends SysModel implements Serializable,GrantedAuthority {

	private static final long serialVersionUID = -4764798374270289681L;

	private Integer roleId;
	private String roleName;
	private String description;
	
	public SysRole() {
		
	}
	
	public SysRole(String roleName) {
		this.roleName = roleName;
	}
	
	/**
	 * 管理员角色
	 */
	public static final String ROLE_ADMIN = "ROLE_ADMIN";
	
	/**
	 * 系统用户角色，当用户被创建时就具有此角色
	 */
	public static final String ROLE_USER = "ROLE_USER";
	
	/**
	 * 老板角色
	 */
	public static final String ROLE_BOSS = "ROLE_BOSS";
	
	/**
	 * 销售经理角色
	 */
	public static final String ROLE_SALER_MANAGER = "ROLE_SALER_MANAGER";
	
	/**
	 * 销售员角色
	 */
	public static final String ROLE_SALER = "ROLE_SALER";
	/**
	 * 角色Id
	 * @return
	 */
	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	/**
	 * 角色名称
	 * @return
	 */
	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	/**
	 * 描述
	 * @return
	 */
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#toString()
	 */
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("roleId",this.roleId)
		  .append("roleName",this.roleName)
		  .append("description",this.description);
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof SysRole)) {
			return false;
		}
		final SysRole role = (SysRole)o;
		if(roleId != null) {
			return roleId.equals(role.getRoleId());
		} else {
			return role.getRoleId() == null;
		}
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.sys.model.SysModel#hashCode()
	 */
	@Override
	public int hashCode() {
		return (this.roleId != null ? this.roleId.hashCode() : 0);
	}

	public String getAuthority() {
		return this.roleName;
	}

}
